#ifndef __STAGE__
#define __STAGE__

#include "sprite.h"
#include "character.h"
#include "item.h"
#include "enemy.h"

using std::vector;

/*! \brief Structure for enemies waves.
* See stage_readme.txt
*/
struct EnemyWave {
  /*! \brief Class constructor.
  *
  */
  EnemyWave();
  /**
  * integer Array.
  * type of enemies (see consts.h)
  */
  int _type[MAX_ENEMY_TYPE];
  /**
  * integer Array.
  * amount of enemies
  */
  int _amount[MAX_ENEMY_TYPE];
  /**
  * integer.
  * Will trigger the wave when the character has reached a certain position.
  * Special values: 0= Trigger disabled, -1= Automatic Trigger.
  */
  int _xTrigger;
  /**
  * integer.
  * Will trigger the wave when the character has killed a certain number of enemies.
  * Special values: 0= Trigger disabled, -1 = Automatic Trigger.
  */
  int _killTrigger;
  /**
  * integer.
  */
  int _killed;
  /**
  * Pointer to the next wave.
  */
  EnemyWave * _next;
};

/*! \brief Stage Class.
*
*/
class Stage : public Sprite {
  public:
    /*! \brief Class constructor.
    *
    * \param filename is the path to the stage config file
    */
    Stage(const char * filename);
    /*! \brief Class destructor.
    *
    * Free the allocated memory.
    */
    ~Stage();
    /*! \brief Main routine.
    *
    * Needed to scroll the stage, move the character, create the enemies.
    */
    int __update();
    /*! \brief Start scrolling the stage.
    *
    * \param speed scrolling speed (in pixel per frames)
    * \param width integer
    */
    void __triggerScroll(int speed, int width);
    /*! \brief Return if the stage is scrolling or not.
    *
    * \return integer
    */
    int __isScrolling();
    /*! \brief Scroll the stage.
    *
    */
    void __scroll();
    /*! \brief Link the character to the stage.
    *
    * The stage needs to know the current position of the player, and so the enemies do
    * \param player pointer to the character
    */
    void __linkCharacter(Character * player);
    /*! \brief Link the Item List to the stage.
    *
    * \param itemVec is a referenced to the Item Vector
    */
    void __linkItemVec(vector<Item *>*itemVec);
    /*! \brief Trigger the enemies creation.
    *
    */
    void __createEnemies();
    
    /*! \brief Update the enemy counter.
    *
    */
    void __killEnemy(int count = 0);
    /*! \brief return the pointer to the stage's title image.
    *
    * \return a bitmap pointer.
    */
    BITMAP * __getTitle();
    /*! \brief Link the HUD vector to the stage.
    *
    * \param HUDVec HUD Vector pointer
    */
    void __linkHUDVec(vector<HUD*>*HUDVec);
    /**
    * Enemy Vector pointer
    *
    */
    vector<Enemy *>* _enemyVec;



  private:
    void __readFile(const char * filename);
    
    BITMAP * _title;    
    int _scrollSpeed, _scrollStatus, _scrollWidth;
    int _currentMap;
    
    Character * _player;
    
    int _enemyOnMap;    
    EnemyWave * _enemyArr[5];
    AnimatedSprite * _enemyPack[5];
    AnimatedSprite * _boss;
    int _bossCreated;
    
    Item * _itemArr[10];    
    vector<Item *>*_itemVec;
    int _itemCreated;
    
    vector<HUD*>* _HUDVec;
};

#endif
